package view;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.event.AncestorListener;

import control.ActListener;
import control.MouseListener;


import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.event.ActionListener;
import java.util.ArrayList;

public class CenterPanel extends JPanel {
	MainF mainF;
	ActListener ac;
	MouseListener mL;
	
	CenterHomePage centerHomePage;
	CenterHouse centerHouse;
	CenterSection centerSection;
	CenterNewHouse centerNewHouse;
	CenterNewPlant centerNewPlant;
	CenterConfigSection centerConfigSection;
	CenterConfigHouse centerConfigHouse;
	ArrayList<String> showHistorie;
	CenterAddPlant centerAddPlant;
	CenterSettings centerSettings;
	CenterStatsPanel centerStatsPanel;
	
	/**
	 * Create the panel.
	 */
	private CardLayout cl_contentPane;
	public CenterPanel(MainF mainF) {
		setLayout(new CardLayout(0, 0));
		setLocation(0, 0);
		setPreferredSize(new Dimension(1280,690));
		setBackground(Color.BLACK);
		this.mainF = mainF;
		this.ac = mainF.getAc();
		this.mL = mainF.getmL();
		showHistorie = new ArrayList<String>();
		
		centerHomePage = new CenterHomePage(mainF);
		add(centerHomePage, "CenterHomePage");
		
		centerHouse = new CenterHouse(mainF);
		JScrollPane jSHouse = new JScrollPane(centerHouse);
		jSHouse.setBorder(new EmptyBorder(0,0,0,0));
		jSHouse.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
		jSHouse.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		jSHouse.getHorizontalScrollBar().setPreferredSize(new Dimension(600,10));
		jSHouse.getHorizontalScrollBar().setUnitIncrement(20);
		jSHouse.getHorizontalScrollBar().setBlockIncrement(20);
		add(jSHouse, "Houses");
		
		
		centerSection = new CenterSection(mainF);
		JScrollPane jSSection = new JScrollPane(centerSection);
		jSSection.setBorder(new EmptyBorder(0,0,0,0));
		jSSection.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
		jSSection.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		jSSection.getHorizontalScrollBar().setPreferredSize(new Dimension(600,10));
		
		jSSection.getHorizontalScrollBar().setUnitIncrement(20);
		jSSection.getHorizontalScrollBar().setBlockIncrement(20);
		add(jSSection, "Sections");
		
		

		centerNewHouse = new CenterNewHouse(mainF);
		add(centerNewHouse,"NewHouse");
		
		centerConfigSection = new CenterConfigSection(mainF);
		add(centerConfigSection,"ConfigSection");
		
		centerNewPlant = new CenterNewPlant(mainF);
		add(centerNewPlant,"NewPlant");
		
		centerConfigHouse = new CenterConfigHouse(mainF);
		add(centerConfigHouse,"ConfigHouse");
		
		centerAddPlant = new CenterAddPlant(mainF);
		add(centerAddPlant,"AddPlant");
		
		centerSettings = new CenterSettings(mainF);
		add(centerSettings,"Settings");
		
		centerStatsPanel = new CenterStatsPanel(mainF);
		add(centerStatsPanel,"StatsPanel");
		
		
		cl_contentPane = (CardLayout)this.getLayout();
		
		
		//addMouseListener(mL);
	}

	public CenterSettings getCenterSettings() {
		return centerSettings;
	}

	public void setCenterSettings(CenterSettings centerSettings) {
		this.centerSettings = centerSettings;
	}

	public CenterAddPlant getCenterAddPlant() {
		return centerAddPlant;
	}

	public void setCenterAddPlant(CenterAddPlant centerAddPlant) {
		this.centerAddPlant = centerAddPlant;
	}

	public void show(String card){
		showHistorie.add(card);
		cl_contentPane.show(this,card);
	}
	public void back(){
		showHistorie.remove(showHistorie.size()-1);
		show(showHistorie.get(showHistorie.size()-1));
	}

	public CenterHomePage getCenterHomePage() {
		return centerHomePage;
	}

	public void setCenterHomePage(CenterHomePage centerHomePage) {
		this.centerHomePage = centerHomePage;
	}
	
	public CenterHouse getCenterHouse() {
		return centerHouse;
	}

	public void setCenterHouse(CenterHouse centerHouse) {
		this.centerHouse = centerHouse;
	}

	public CenterNewHouse getCenterNewHouse() {
		return centerNewHouse;
	}

	public void setCenterNewHouse(CenterNewHouse centerNewHouse) {
		this.centerNewHouse = centerNewHouse;
	}

	public CenterSection getCenterSection() {
		return centerSection;
	}

	public void setCenterSection(CenterSection centerSection) {
		this.centerSection = centerSection;
	}

	public CenterNewPlant getCenterNewPlant() {
		return centerNewPlant;
	}

	public void setCenterNewPlant(CenterNewPlant centerNewPlant) {
		this.centerNewPlant = centerNewPlant;
	}

	public CenterConfigSection getCenterConfigSection() {
		return centerConfigSection;
	}

	public void setCenterConfigSection(CenterConfigSection centerConfigSection) {
		this.centerConfigSection = centerConfigSection;
	}

	public CenterConfigHouse getCenterConfigHouse() {
		return centerConfigHouse;
	}

	public void setCenterConfigHouse(CenterConfigHouse centerConfigHouse) {
		this.centerConfigHouse = centerConfigHouse;
	}

	public CenterStatsPanel getCenterStatsPanel() {
		return centerStatsPanel;
	}

	public void setCenterStatsPanel(CenterStatsPanel centerStatsPanel) {
		this.centerStatsPanel = centerStatsPanel;
	}
}
